package com.danger.Presenter;

import android.content.Context;

import com.danger.Model.action.UploadPhotoModel;
import com.danger.Model.action.UploadPhotoModelImpl;
import com.danger.Model.listener.OnCommonListener;
import com.danger.View.UploadPhotoView;

/**
 * Created by danger on 2016/4/4.
 */
public class UploadPhotoPresenterImpl implements UploadPhotoPresenter {

    private Context context;
    private UploadPhotoModel model;
    private UploadPhotoView view;

    public UploadPhotoPresenterImpl(Context context, UploadPhotoView view) {
        this.context = context;
        this.view = view;
        model = new UploadPhotoModelImpl(context);
    }

    @Override
    public void upload(String path) {
        view.showDialog();
        model.upload(path, new OnCommonListener() {
            @Override
            public void onSuccess(String url) {
                view.hideDialog();
                view.showSuccess("上传成功", url);
                view.toNext();
            }

            @Override
            public void onError(String s) {
                view.hideDialog();
                view.showError(s);
            }
        });
    }
}
